#include "inherit.h"
#include <iostream>

Object::Object()
{
    mName = "Object";
    mInfo = "";
}

string Object::name()
{
    return mName;
}

string Object::info()
{
    return mInfo;
}

Point::Point(int x, int y)
{
    ostringstream s;

    mX = x;
    mY = y;
    mName = "Point";

    s << "P(" << mX << ", " << mY << ")";

    mInfo = s.str();
}

int Point::x()
{
    return mX;
}

int Point::y()
{
    return mY;
}


Line::Line(Point p1, Point p2)
{
    ostringstream s;

    mP1 = p1;
    mP2 = p2;
    mName = "Line";

    s << "Line from " << mP1.info() << " to " << mP2.info();

    mInfo = s.str();
}

Point Line::begin()
{
    return mP1;
}

Point Line::end()
{
    return mP2;
}

int inherit_main(void)
{
    Object o;
    Point p(1, 2);
    Point pn(5, 6);
    Line l(p, pn);

    cout << o.name() << endl;
    cout << o.info() << endl;

    cout << endl;

    cout << p.name() << endl;
    cout << p.info() << endl;

    cout << endl;

    cout << l.name() << endl;
    cout << l.info() << endl;

    return 0;
}
